package models;

import java.util.Date;
import java.util.LinkedList;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import play.db.jpa.Model;

@Entity
public class Payement extends Model {
	
	public Date date;
	public Double amount;
	
	@ManyToOne
	public Register registration;
	
	public Payement(Date date, Double amount, Register registration) {
		
		this.date = date;
		this.amount = amount;
		this.registration = registration;
	}

	public static LinkedList<Payement> generatePayements(LinkedList<Date> d
							, LinkedList<Double> amounts){
		
		LinkedList<Payement> p = new LinkedList<Payement>();
		for(int i = 0 ; i < amounts.size() ; i++) {
			
			p.add(new Payement(d.get(i),amounts.get(i),null));
		}
		return p;
		
	}
	
	@SuppressWarnings("deprecation")
	public static String dateMonth() {
		
		int m = new Date().getMonth();
		int y = new Date().getYear()+1900;
		
		String mth = "";
		
		switch(m) {
		case 0: mth="January";break;
		case 1: mth="February";break;
		case 2: mth="March";break;
		case 3: mth="April";break;
		case 4: mth="May";break;
		case 5: mth="June";break;
		case 6: mth="July";break;
		case 7: mth="August";break;
		case 8: mth="September";break;
		case 9: mth="October";break;
		case 10: mth="November";break;
		case 11: mth="December";break;
		
		
		
		}
		
		return mth + " " + y;
		
	}
	
	
	

}
